#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// Q3. 划分数组得到最小 XOR
// https://leetcode.cn/contest/weekly-contest-456/problems/partition-array-to-minimize-xor/description/

class Solution
{
public:
    bool check(vector<int> &nums, int k, int val)
    {
        int cnt = 0;
        int curXor = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            curXor ^= nums[i];
            if(curXor <= k){
                cnt++;
                curXor = 0;
            }
        }
        return cnt >= k;
    }
    int minXor(vector<int> &nums, int k)
    {
        int left = 0;
        int right = *max_element(nums.begin(), nums.end());
        int ans = right;
        while (left < right)
        {
            int mid = (right - left) / 2 + left;
            if(check(nums, k, mid)){
                ans = mid;
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}